package com.hy.study.mapper;

import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;

import java.io.IOException;

/**
 * @author huyong
 * @date 2024 年 02 月 07 日 15:30: 19
 */
public class TwoIndexMapper extends Mapper<LongWritable, Text, Text, Text> {
    private final Text k = new Text();
    private final Text v = new Text();

    @Override
    protected void map(LongWritable key, Text value, Mapper<LongWritable, Text, Text, Text>.Context context) throws IOException, InterruptedException {
        String line = value.toString();
        String[] split = line.split("--");
        String word = split[0];
        String vstr = split[1];
        k.set(word);
        v.set(vstr);
        context.write(k, v);
    }
}
